﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class ChucNang_Admin_Admi_XoaPhanLoai : System.Web.UI.Page
{
    int id;
    DataDSTableAdapters.PHANLOAITableAdapter plapdapter = new DataDSTableAdapters.PHANLOAITableAdapter();
    DataDS.PHANLOAIDataTable table = new DataDS.PHANLOAIDataTable();
    protected void Page_Load(object sender, EventArgs e)
    {
        
        id = int.Parse(Request.QueryString["Id"].ToString());
        if(id==null)
            Response.Redirect("Admin_XemDanhSachPhanLoai.aspx");
        table = plapdapter.PHANLOAI_LayTheoId(id);
        if (table.Rows.Count != 0)// tranh truong hop sao khi xóa xong load bi loi
        {
            lbTenPhanLoai.Text = table.Rows[0]["TenPhanLoai"].ToString();
        }
    }
    protected void btnXacNhan_Click(object sender, EventArgs e)
    {
        int? kq=0;
        plapdapter.PHANLOAI_XoaTheoId(id,ref kq);
        if (kq == 0)
            Response.Write("<script>alert('Xóa thành công');location.href='Admin_XemDanhSachPhanLoai.aspx';</script>");
        else
            Response.Write("<script>alert('Xóa không thành công');location.href='Admin_XemDanhSachPhanLoai.aspx';</script>");

    }
    protected void btnTroLai_Click(object sender, EventArgs e)
    {
        Response.Redirect("Admin_XemDanhSachPhanLoai.aspx");
    }
}
